#include <iostream>
#include <fstream>
#include <string>
using std::cerr;
using std::cout;
using std::endl;
using std::ifstream;
using std::string;


//希望利用read函数，一次性读取文件的所有内容
void test0(){
    //开始就将文件游标设置在结尾位置
    ifstream ifs("3.inputInt.cc",std::ios::ate);

    if(!ifs)
    {
        cerr << "ifstream open file failed" << endl;
        return;
    }

    /* ifs.seekg(0,std::ios::end); */
    long length = ifs.tellg();

    /* ifs.seekg(0); */
    ifs.seekg(0,std::ios::beg);
    char * data = new char[length + 1]();
    ifs.read(data,length);

    /* cout << data << endl; */
    string str1(data);

    delete [] data;
    data = nullptr;

    cout << str1 << endl;

    ifs.close();
}

int main(void){
    test0();
    return 0;
}
